package com.sailing.lianxi.io.nio;

import java.io.FileOutputStream;
import java.nio.file.FileStore;
import java.nio.file.Files;
import java.nio.file.Paths;


/**
 * FilesTest操作
 * @author Administrator
 *
 */
public class FilesTest {

	public static void t1(){
		//复制文件
		try {
//			Files.copy(Paths.get("FilesTest.java"),new FileOutputStream("a.txt"));
			//使用java8新增的Stream API列出当前目录下所有文件和子目录
//			Files.list(Paths.get(".")).forEach(path->System.out.println());
			FileStore cStore = Files.getFileStore(Paths.get("."));
			// 判断C盘的总空间，可用空间
			System.out.println("C:共有空间：" + cStore.getTotalSpace()/1024/1024/1024);
			System.out.println("C:可用空间：" + cStore.getUsableSpace()/1024/1024/1024);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		
	}
	
	public static void main(String[] args) {
		t1();
	}
}
